let flag = 0  
export const $http = (params)=>{
  flag++
  wx.showLoading({
    title: '加载中',
    mask: true
  });
  
  const baseURL = 'https://api-hmugo-web.itheima.net/api/public/v1'
  return new Promise((resolve,reject)=>{
    wx.request({
      ...params,
      url:baseURL+params.url,
      success:(result)=>{
        resolve(result.data.message)
      },
      fail:(err)=>{
        reject(err)
      },
      complete:()=>{
        flag--
        if(flag ===0){
          wx.hideLoading()
        }
      }
    })
  })
}




